﻿namespace WPFDBBrowser.MessageBus
{
    using System;

    public class EndPoint : IEndPoint
    {
        #region IEndPoint Members

        public IMessageBus Bus { get; set; }

        public string Address { get; set; }

        public IEndPoint Start()
        {
            return Bus.Start(Address);
        }

        public IEndPoint Stop()
        {
            return Bus.Stop(Address);
        }

        public IEndPoint Publish<TMessage>(TMessage message)
        {
            return Bus.Publish<TMessage>(Address, message);
        }

        public IEndPoint Subscribe<TMessage>(Guid subscriptionId, Action<TMessage> notify)
        {
            return Bus.Subscribe<TMessage>(Address, subscriptionId, notify);
        }

        public IEndPoint Subscribe<TMessage>(Guid subscriptionId, Action<TMessage> notify, Predicate<TMessage> filter)
        {
            return Bus.Subscribe<TMessage>(Address, subscriptionId, notify, filter);
        }

        public IEndPoint Send<TMessage>(TMessage message, string address)
        {
            return Bus.Send<TMessage>(Address, message, address);
        }

        public IEndPoint Send<TRequest, TResponse>(TRequest request, string address, Action<TResponse> reply)
        {
            return Bus.Send<TRequest, TResponse>(Address, request, address, reply);
        }

        public IEndPoint UnSubscribe(Guid subscriptionId)
        {
            return Bus.UnSubscribe(subscriptionId);
        }

        #endregion
    }
}
